<?php
require_once 'DbMgr.php';
require_once 'main.php';

class Region {

	var $nom = "region";

	var $image = "image";

	var $chef_lieu = "chef_lieu"; 

	var $population = 0;

	var $superficie = 0;

	var $localisation = "localisation";

	function Region($nom_region)
	{ 
		$res = $this->obtenirInfoRegion($nom_region);

		foreach($res as $cle=>$val){
			$this->nom = $val["nom"];
			$this->image = $val["image"];
			$this->chef_lieu = $val["chef_lieu"];
			$this->population = $val["population"];
			$this->superficie = $val["superficie"];
			$this->loacalisation = $val["localisation"];
		}
	}

	function obtenirInfoRegion($region)
	{
		$dbMgr = new DbMgr();
		$dbMgr->connexion("mysql");

		$tmpRegion = str_replace("'", "\'", $region);

		$query = "SELECT * FROM regions WHERE nom = '$tmpRegion';";
		$res = $dbMgr->select($query);
		return $res;
	}

	static function rechercheRegions($localisation)
	{
		$dbMgr = new DbMgr();
		$dbMgr->connexion("mysql");
		$address = stripslashes($localisation);
		$query = "SELECT nom FROM regions WHERE localisation = '$localisation';";
		$res = $dbMgr->select($query);
		return $res;
	}
}
?>
